x86/shadow: tolerate failure of sh_set_toplevel_shadow()
authorJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 12:53:12 +0000 (14:53 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 11 Oct 2022 12:53:12 +0000 (14:53 +0200)
commit40e9daf6b56ae49bda3ba4e254ccf0e998e52a8c
treeecef218589363b4555fc8c1b8ecc99a4ea24f7f3
parent3422c19d85a3d23a9d798eafb739ffb8865522d2
x86/shadow: tolerate failure of sh_set_toplevel_shadow()

Subsequently sh_set_toplevel_shadow() will be adjusted to install a
blank entry in case prealloc fails. There are, in fact, pre-existing
error paths which would put in place a blank entry. The 4- and 2-level
code in sh_update_cr3(), however, assume the top level entry to be
valid.

Hence bail from the function in the unlikely event that it's not. Note
that 3-level logic works differently: In particular a guest is free to
supply a PDPTR pointing at 4 non-present (or otherwise deemed invalid)
entries. The guest will crash, but we already cope with that.

Really mfn_valid() is likely wrong to use in sh_set_toplevel_shadow(),
and it should instead be !mfn_eq(gmfn, INVALID_MFN). Avoid such a change
in security context, but add a respective assertion.

This is part of CVE-2022-33746 / XSA-410.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
master commit: eac000978c1feb5a9ee3236ab0c0da9a477e5336
master date: 2022-10-11 14:22:24 +0200
xen/arch/x86/mm/shadow/common.c
xen/arch/x86/mm/shadow/multi.c